package com.mchsdk.paysdk.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.mchsdk.paysdk.activity.fragments.ToCertificateFragment;
import com.mchsdk.paysdk.activity.fragments.ToCertificateNoFragment;
import com.mchsdk.paysdk.activity.fragments.ToCertificateOKFragment;
import com.mchsdk.paysdk.adapter.CertificateVpAdapter;
import com.mchsdk.paysdk.common.Constant;
import com.mchsdk.paysdk.http.process.CertificateProcess;
import com.mchsdk.paysdk.utils.MCHInflaterUtils;
import com.mchsdk.paysdk.utils.MCLog;
import com.mchsdk.paysdk.utils.ToastUtil;
import com.mchsdk.paysdk.view.util.NoScrollViewPager;

import java.security.cert.Certificate;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/5/3.
 */

/**
 * 去认证Activity
 */
public class ToCertificateActivity extends MCBaseFragmentActivity {


    private final static String TAG = "ToCertificateActivity";
    private Context mContext;
     int y = 0;
    private List<Fragment> frag;
    private NoScrollViewPager mVp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(MCHInflaterUtils.getLayout(ToCertificateActivity.this, "activity_mch_certificate"));
        mContext = ToCertificateActivity.this;
        frag = new ArrayList<Fragment>();
        frag.add(new ToCertificateNoFragment());
        frag.add(new ToCertificateOKFragment());
        frag.add(new ToCertificateFragment());
        initViews();
    }

    private void initViews() {
        MCLog.e(TAG, "fun#initView");
        //TODO: ----------------标题栏初始化-----------------

        TextView txtTitle = (TextView) findViewById(MCHInflaterUtils
                .getControl(this, "tv_mch_header_title"));
        txtTitle.setText("实名认证");
        txtTitle.setGravity(Gravity.CENTER | Gravity.CENTER_VERTICAL);
        ImageView ivBack = (ImageView) findViewById(MCHInflaterUtils
                .getControl(this, "iv_mch_header_back"));
        ivBack.setVisibility(View.VISIBLE);
        ivBack.setOnClickListener(backClick);

        ImageView ivClose = (ImageView) findViewById(MCHInflaterUtils
                .getControl(this, "iv_mch_header_close"));
        ivClose.setVisibility(View.GONE);
        ivClose.setOnClickListener(backClick);
         Intent intent = getIntent();
         String type = intent.getStringExtra("type");
        if (type.equals("0")){
            y = 0;
        }else if (type.equals("2")){
            y = 2;
        }
        //TODO: ------------控件初始化----------------------
        mVp = (NoScrollViewPager) findViewById(MCHInflaterUtils
                .getControl(this, "mch_certificate_vp"));

        CertificateVpAdapter vpAdapter = new CertificateVpAdapter(getSupportFragmentManager(),frag);
        mVp.setAdapter(vpAdapter);

        showFragment(y);

    }

    public void showFragment(int i) {
        mVp.setCurrentItem(i);
    }


    /**
     * 关闭监听
     */
    View.OnClickListener backClick = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    };


}